<template>
  <div class="ces-search">
    <el-form ref="refForm" class="form" :size="size" inline :label-width="labelWidth">
      <el-form-item v-for="item in searchForm" :key="item.prop" :label="item.label" class="formItem">
        <!-- 输入框 -->
        <el-input v-if="item.type==='Input'" v-model="searchData[item.prop]" size="mini" :style="{width:item.width}" />
        <!-- 下拉框 -->
        <el-select v-if="item.type==='Select'" v-model="searchData[item.prop]" size="mini" :style="{width:item.width}" @change="item.change(searchData[item.prop])">
          <el-option v-for="op in item.options" :key="op.value" :label="op.label" :value="op.value" />
        </el-select>
        <!-- 单选 -->
        <el-radio-group v-if="item.type==='Radio'" v-model="searchData[item.prop]">
          <el-radio v-for="ra in item.radios" :key="ra.value" :label="ra.value">{{ ra.label }}</el-radio>
        </el-radio-group>
        <!-- 单选按钮 -->
        <el-radio-group v-if="item.type==='RadioButton'" v-model="searchData[item.prop]" @change="item.change && item.change(searchData[item.prop])">
          <el-radio-button v-for="ra in item.radios" :key="ra.value" :label="ra.value">{{ ra.label }}</el-radio-button>
        </el-radio-group>
        <!-- 复选框 -->
        <el-checkbox-group v-if="item.type==='Checkbox'" v-model="searchData[item.prop]">
          <el-checkbox v-for="ch in item.checkboxs" :key="ch.value" :label="ch.value">{{ ch.label }}</el-checkbox>
        </el-checkbox-group>
        <!-- 日期 -->
        <el-date-picker v-if="item.type==='Date'" v-model="searchData[item.prop]" />
        <!-- 时间 -->
        <el-time-select v-if="item.type==='Time'" v-model="searchData[item.prop]" type="" />
        <!-- 日期时间 -->
        <el-date-picker v-if="item.type==='DateTime'" v-model="searchData[item.prop]" type="datetime" :disabled="item.disable && item.disable(searchData[item.prop])" />
        <!-- 日期范围 -->
        <el-date-picker v-if="item.type==='datetimerange'" v-model="searchData[item.prop]" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
        <!-- 滑块 -->
        <!-- <el-slider v-if="item.type==='Slider'" v-model="searchData[item.prop]"></el-slider> -->
        <!-- 开关 -->
        <el-switch v-if="item.type==='Switch'" v-model="searchData[item.prop]" />
      </el-form-item>
    </el-form>
    <el-form v-if="isHandle" class="formT" inline>
      <el-form-item v-for="(item , index) in searchHandle" :key="index">
        <el-button :type="item.type" :size="item.size || size" @click="item.handle()">{{ item.label }}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    isHandle: {
      type: Boolean,
      default: true
    },
    labelWidth: {
      type: String,
      default: '50px'
    },
    size: {
      type: String,
      default: 'mini'
    },
    searchForm: {
      type: Array,
      // eslint-disable-next-line vue/require-valid-default-prop
      default: []
    },
    searchHandle: {
      type: Array,
      default: () => []
    },
    searchData: {
      type: Object,
      // eslint-disable-next-line vue/require-valid-default-prop
      default: {}
    }
  },
  data() {
    return {
    }
  },
  methods: {

  }

}

</script>
<style lang="scss" >
 .ces-search{
    display: flex;
    justify-content: space-between;
    .formItem{
        .el-form-item__label{
            width: 80px !important;
        }
    }
    .el-form-item__content{
      line-height: 0px;
    }
 }

</style>
